//  Created by <Omar MALAGOUEN>

//  Copyright 2011 All rights reserved.
//


/*
 * Various utilities for command line tools
 * Copyright (c) 2000-2010 Omar Malagouen
 *
 * This file is part of Kakola.
 *
 * Kakola is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Kakola is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Kakola; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef COPTIONS_H
#define COPTIONS_H

#include <QtGui/QDialog>
#include <QFileDialog>
#include <QListWidget>
#include <QHash>
#include "kakola.h"

namespace Ui {
    class COptions;
}

class COptions : public QDialog{
    Q_OBJECT
    Q_DISABLE_COPY(COptions)
public:
            explicit COptions(QWidget *parent = 0);
    virtual ~COptions();
    void showDialog(void);

    int systemNumberOfCPU;
    QString arch;
    QString overwrite;
    QString     ffmpeg;
    QString     mencoder;
    QString     language;
    int         langueIndex;
    QString     homeDir;
    QString     userName;
    QString     tmpDir;
    QString system;
    QString     profileDir;
    QString     applicationDir;
    QString     homeDrive;
    QString     destinationDirectory;
    QString     lastDirectory;
    int         numberOfCPUToUse;
    int init;
    QString destinationDirectorySimpleView;
    QString defaultProfile; // the file name of the default profile
    QString defaultProfileDescr; // the descr of the default profile
    int getIndexOfProfileInComboBox(QString, QString);
    int getIndexOfDefaultProfileInComboBox();
    QSettings *settings;
    QListWidget *optionListProfileInCombo;

    int indexOfCProfile(CProfile *);
    int populateListWidget(QListWidget *, QString, QString);


    void populateComboBox(QComboBox*,QString,QString,QListWidget *,QString, QString);
    void populateComboBox(QString,QString,QListWidget *,QString, QString);
    bool createDirectory(QString);
    QHash< QString, QList<CProfile*> > hashProfileGroup;
    void getListProfileFile(QString);
    void appendToProfileCombo(QString );
    void updateProfileCombo(int,QString );
    void initEnvironnementVariable(void);
    void printOptionsValue(void);
    CProfile* getProfileAt(int);

protected:
    virtual void changeEvent(QEvent *e);

private:
    Ui::COptions *m_ui;

public slots:
    void on_pushButtonApply_clicked();
    void on_langueComboBox_activated(int);
    //void on_pushButton_clicked();
    void on_toolButtonChoisir_2_clicked();
    void on_toolButtonChoisir_clicked();
    void on_pushButtonCancel_clicked();
    void on_toolButtonChoisir_mencoder_clicked();
};

#endif // COPTIONS_H

